// es5 构造函数
// 函数表达式
const MiniStack = function() {
    this.stack = [];    //数组
}
MiniStack.prototype.push = function(x) {
    this.stack.push(x);
}
MiniStack.prototype.pop = function(){
    return this.stack.pop()
}
MiniStack.prototype.top = function() {
    if(!this.stack || this.stack.length) {
        return ;
    }
    return this.stack[this.stack.length-1];
}
// O(n)
MiniStack.prototype.getMin = function (){
    // 遍历一遍
    // Infinity 无穷大
    let minValue = Infinity;  //无穷大
    const { stack } = this;
    for(let i = 0; i<stack.length; i++) {
        if(stack[i] < minValue) {
            minValue = stack[i];
        }
    }
    return minValue;
}